home *** CD-ROM | disk | FTP | other *** search
/ Ultimedia 1 / Ultimedia 1.iso / tools / grafiktools / showpicasso / source / sp_tools.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-08  |  2.3 KB  |  101 lines

  1. /* Unterprogramme für ShowPicasso
  2. ** File: tools.c
  3. */
  4.  
  5.  
  6. #include "sp_tools.h"
  7.  
  8.  
  9. /* Umwandlung eines String in LONG */
  10.  
  11. LONG stol(UBYTE *str)
  12. {
  13.  LONG i=NULL,j=strlen(str),l=NULL;
  14.  
  15.  if(!str) return(NULL);
  16.  
  17.  while((i < j) && (str[i] > 47) && (str[i] < 58))
  18.  {
  19.   l += (str[i] - 48);
  20.   l *= 10;
  21.   i++;
  22.  }
  23.  
  24.  return(l / 10);
  25. }
  26.  
  27. /* Ausgabe von Programmeldungen */
  28.  
  29. VOID OutText(UBYTE *str)
  30. {
  31.  if(USERFLGS & PFLG_WBSTART)
  32.  {
  33.   msgreq.es_TextFormat = str;
  34.   EasyRequest(NULL,&msgreq,NULL,NULL);
  35.   /* rtEZRequestA( str, "Ok", NULL, NULL, NULL); */
  36.  }
  37.  else VPrintf("%s\n",&str);
  38. }
  39.  
  40.  
  41. /* Öffnen der benötigten Libraries */
  42.  
  43.  
  44. BOOL OpenLibs(void)
  45. {
  46.  if(!(IntuitionBase = OpenLibrary("intuition.library",LIBRARY_MIN))) return(FALSE);
  47.  if(!(IconBase = OpenLibrary("icon.library",LIBRARY_MIN)))           return(FALSE);
  48.  if(!(WorkbenchBase = OpenLibrary("workbench.library",LIBRARY_MIN))) return(FALSE);
  49.  if(!(AslBase = OpenLibrary("asl.library",LIBRARY_MIN)))             return(FALSE);
  50.  if(!(GfxBase = OpenLibrary("graphics.library",LIBRARY_MIN)))        return(FALSE);
  51.  if(!(IFFParseBase = OpenLibrary("iffparse.library",LIBRARY_MIN)))   return(FALSE);
  52.  if(!(VilIntuiBase = OpenLibrary("vilintuisup.library",0)))          return(FALSE);
  53.  /* if(!(ReqToolsBase = OpenLibrary("reqtools.library",38L)))             return(FALSE); */
  54.  LocaleBase = OpenLibrary("locale.library",38L);
  55.  return(TRUE);
  56. }
  57.  
  58.  
  59. /* Schließen der Libraries  */
  60.  
  61.  
  62. void CloseLibs(void)
  63. {
  64.  if(IntuitionBase) CloseLibrary(IntuitionBase);
  65.  if(IconBase) CloseLibrary(IconBase);
  66.  if(WorkbenchBase) CloseLibrary(WorkbenchBase);
  67.  if(AslBase) CloseLibrary(AslBase);
  68.  if(GfxBase) CloseLibrary(GfxBase);
  69.  if(IFFParseBase) CloseLibrary(IFFParseBase);
  70.  if(VilIntuiBase) CloseLibrary(VilIntuiBase);
  71.  /* if(ReqToolsBase) CloseLibrary(ReqToolsBase); */
  72.  if(LocaleBase) CloseLibrary(LocaleBase);
  73. }
  74.  
  75.  
  76. /* Speicherreservierung */
  77.  
  78.  
  79. BOOL GetWorkSpace(VOID)
  80. {
  81.  ULONG workspace = cbufsize + 852L; /* (ULONG)sizeof(BitMapHeader) + 768L + 64L */
  82.  
  83.  if(cbuf = AllocVec(workspace,MEMF_PUBLIC|MEMF_CLEAR))
  84.  {
  85.   color = cbuf + cbufsize;
  86.   bmhd = (BitMapHeader *)(color + 768L); /* 256 * 3 (r,g,b) = 768 */
  87.   mynamebuffer = (UBYTE *)(bmhd + 20L); /* (ULONG)sizeof(BitMapHeader) */ 
  88.   return(TRUE);
  89.  }
  90.  return(FALSE);
  91. }
  92.  
  93.  
  94. /* Freigabe des Speichers */
  95.  
  96.  
  97. VOID FreeWorkSpace(VOID)
  98. {
  99.  if(cbuf) FreeVec(cbuf);
  100. }
  101.